Militant group Al Shabaab said it was behind the attack on Hawlwadag district office, which also blew off the roof of a mosque and damaged houses nearby.
At least six people had been killed, including soldiers, civilians and the suicide bomber, and a dozen injured, according to police officer Mohamed Hussein.
The school was open but at the time of the blast most children were away from the building on a break.
Earlier, the director of the Amin ambulance service told Reuters that at least 14 people had been injured, including 6 children.
Abdiasis Abu Musab, Al Shabaab’s military operations spokesman, said the group had carried out the attack.
“We are behind the suicide attack. We targeted the district office in which there was a meeting. We killed 10 people so far, we shall give details later.”
Somalia has been wracked by lawlessness and violence since 1991. Terrorist group al Shabaab is fighting to dislodge a Western-backed government protected by African Union-mandated peacekeepers.